Repository navigation
docs: show a custom input provider for Flow.ask() - #8809
Felix Shi (shi-felix) wants to merge 3 commits into
Conversation
Preview approval requiredThis pull request comes from a fork, so Mintlify won't build a preview until someone with write access approves commit |
Strix Security ReviewWarning This pull request has 117 commits after the last Strix review ( ✅ No open security findings. PR summary: This PR adds documentation for `Flow.ask()` input providers across four locales and exposes a read-only `Flow.input_history` property returning a copy of the existing private `_input_history` list, plus tests for both the property and the documented example. Review summaryNo security issues found. The diff makes one functional change and it reduces exposure rather than adding it: the GraphQL query now receives Review 1 on this PR · Reviewed by Strix |
Summary
Flow.ask()has anInputProviderextension point, but the guides never showed it, so the only documented way to answer a question was the console. This adds a runnable scripted provider — and exposes theflow.input_historyAPI that the issue points at, which did not actually exist onmain.Fixes #8071.
The
input_historygapconversation.pydocumentsFlow.input_historyandinput_provider.pysays response metadata is"stored in
_input_history", butFlowonly has the private_input_historyattribute —flow.input_historyraisesAttributeError. The example needs to inspect response metadata, so thisPR adds a read-only property that returns a copy of the private list. It adds no new abstraction and
does not change how entries are recorded.
Changes
lib/crewai/src/crewai/flow/runtime/__init__.py: aninput_historyproperty next tostate/method_outputs, returninglist(self._input_history)so callers cannot mutate the record.docs/edge/en/concepts/flows.mdx: a new "Collecting Input withask()" section with the completescripted_input.py, the run command, expected output, the request/response metadata round trip, theNone(no input available) path, and howask()differs fromhandle_turn().docs/edge/{ar,ko,pt-BR}/concepts/flows.mdx: the same section in each locale.docs/edge/{en,ar,ko,pt-BR}/guides/flows/conversational-flows.mdx: a one-paragraph cross-link from the conversational guide to the new section.lib/crewai/tests/test_flow_ask.py: a test for the public property (including that it returns a copy), andTestDocumentedScriptedProviderExample, which runs the documented flow and asserts the metadata round trip and the unavailable-input path.Testing
The documented script prints exactly what the guide claims:
ruff checkon the touched file reports oneF401(typing.Literalunused, line 3923) that alsofails on unmodified
main; I left it alone to keep this diff focused.Python 3.13.14 on Windows. No credentials, no stdin, no model calls.
AI assistance
Written with AI assistance (WorkBuddy) and reviewed before submission.
Note
Low Risk
Documentation and a read-only accessor with copy semantics; no change to how
ask()records input or to conversational turn APIs.Overview
Documents custom input providers for
Flow.ask()and closes a small API gap so the new guide can show metadata and audit trails.Runtime: Adds a read-only
flow.input_historyproperty that returns a copy of the existing_input_historylist (same fields as before: message, response, method name, timestamps, request/response metadata). Recording behavior is unchanged; callers no longer need to touch the private attribute.Docs: New “Collecting Input with
ask()” section in English, Arabic, Korean, and pt-BR concepts/flows pages — scriptedInputResponseprovider,Nonewhen no input,input_historyinspection, andask()vshandle_turn(). Conversational flows guides in those locales get a short cross-link when a question belongs inside one step.Tests: Asserts
input_historymatches internal records and is immutable via copy, plus a test that runs the documentedSurveyFlow/ScriptedProviderexample.Reviewed by Cursor Bugbot for commit 2dd221a. Bugbot is set up for automated code reviews on this repo. Configure here.